package com.haipi.util.mail;

import com.haipi.model.CommInitial;

public class MailUtil {

	 public static String SERVET_HOST = (String)CommInitial.initialParamMap.get("mail.server.smtp");
     public static String SERVET_PORT = (String)CommInitial.initialParamMap.get("mail.server.port");
     public static String USER_NAME = (String)CommInitial.initialParamMap.get("mail.server.username");
     public static String PASSWORD = (String)CommInitial.initialParamMap.get("mail.server.password");
     public static String FROM_ADDR = (String)CommInitial.initialParamMap.get("mail.server.fromaddress");

	public static void send(String subject, String content, String toAddr) {
		MailSenderInfo mailInfo = new MailSenderInfo();
		mailInfo.setMailServerHost(SERVET_HOST);
		mailInfo.setMailServerPort(SERVET_PORT);
		mailInfo.setValidate(true);
		mailInfo.setUserName(USER_NAME);
		mailInfo.setPassword(PASSWORD);
		mailInfo.setFromAddress(FROM_ADDR);
		mailInfo.setToAddress(toAddr);
		mailInfo.setSubject(subject);
		mailInfo.setContent(content);

		MailSendTask task = new MailSendTask(mailInfo);
		MailThreadPool.getInstance().execute(task);
	}
}
